<template>
  <el-dialog
    title="查询条件"
    :close-on-click-modal="false"
    :visible.sync="visible"
    append-to-body>
    <el-form :model="dataForm" style="padding:10px 30px" ref="dataForm" label-width="100px">
      <el-row>
        <el-col :span="12">
          <el-form-item label="姓名">
            <el-input v-model="dataForm.name" placeholder="请填写姓名"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="身份证号">
            <el-input v-model="dataForm.idCard" placeholder="请填写身份证号"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="手机号">
            <el-input v-model="dataForm.mobile" placeholder="请填写手机号"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="学历">
            <el-select v-model="dataForm.academic" placeholder="请选择学历" style="width:100%">
              <el-option
                v-for="item in academics"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="职务">
            <el-input v-model="dataForm.jobGrade" placeholder="请填写职务"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="入职时间">
            <el-date-picker type="date" v-model="dataForm.entryTime" placeholder="选择入职时间" style="width:100%"></el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="合同到期">
            <el-date-picker type="date" v-model="dataForm.contractExpirationTime" placeholder="选择合同到期" style="width:100%"></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="状态">
            <el-select v-model="dataForm.status" placeholder="请选择状态" style="width:100%">
              <el-option
                v-for="item in statuses"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    data () {
      return {
        visible: false,
        dataForm: {
          name: '',
          idCard: '',
          mobile: '',
          academic: '',
          jobGrade: '',
          entryTime: '',
          contractExpirationTime: '',
          status: ''
        },
        academics: [{
          value: '博士',
          label: '博士'
        }, {
          value: '硕士',
          label: '硕士'
        }, {
          value: '本科',
          label: '本科'
        }, {
          value: '专科',
          label: '专科'
        }, {
          value: '高职高专',
          label: '高职高专'
        }, {
          value: '中专',
          label: '中专'
        }, {
          value: '高中',
          label: '高中'
        }, {
          value: '初中',
          label: '初中'
        }, {
          value: '小学',
          label: '小学'
        }, {
          value: '其他',
          label: '其他'
        }],
        statuses: [
          {
            value: '',
            label: '全部'
          }, {
            value: 1,
            label: '有效'
          }, {
            value: 0,
            label: '删除'
          }
        ]
      }
    },
    mounted() {
      this.restForm()
    },
    methods: {
      init(){
        this.visible = true
      },
      restForm(){
        this.dataForm = {
          name: '',
          idCard: '',
          mobile: '',
          academic: '',
          jobGrade: '',
          entryTime: '',
          contractExpirationTime: '',
          status: ''
        }
      },
      dataFormSubmit () {
        let params = {
          'name': this.dataForm.name,
          'idCard': this.dataForm.idCard,
          'mobile': this.dataForm.mobile,
          'academic': this.dataForm.academic,
          'jobGrade': this.dataForm.jobGrade,
          'entryTime': this.$dateFormatNoTime(this.dataForm.entryTime),
          'contractExpirationTime': this.$dateFormatNoTime(this.dataForm.contractExpirationTime),
          'status': this.dataForm.status
        }
        this.visible = false
        this.$emit('refreshDataList', params)
        this.dataForm = {
          name: '',
          idCard: '',
          mobile: '',
          academic: '',
          jobGrade: '',
          entryTime: '',
          contractExpirationTime: '',
          status: ''
        }
      }
    }
  }
</script>
